package com.hamizhong.iflowers.web.action.admin.statics;

import net.sf.json.JSONObject;

import com.hamizhong.iflowers.service.IVarietyService;
import com.hamizhong.iflowers.utils.MyConstants;
import com.hamizhong.iflowers.web.base.MyBaseAjaxAction;
import com.hamizhong.iflowers.web.dto.IOPResultDto;
import com.hamizhong.iflowers.web.vo.IObjectVO;
import com.hamizhong.iflowers.web.vo.VarietyVO;

public class AjaxDeleteVarietyAction extends MyBaseAjaxAction {
	
	private IVarietyService iVarietyService = null;
	
	public IVarietyService getiVarietyService() {
		return iVarietyService;
	}
	public void setiVarietyService(IVarietyService iVarietyService) {
		this.iVarietyService = iVarietyService;
	}
	
	@Override
	protected JSONObject doRequest() {
		logger.info("...invoke...AjaxDeleteVarietyAction...");
		String varietyId = getRQ().getParameter("varietyId");
		IOPResultDto<IObjectVO> resultDto = new IOPResultDto<IObjectVO>();
		VarietyVO varietyVO = new VarietyVO();
		varietyVO.setVarietyId(varietyId);
		resultDto = iVarietyService.deleteVariety(varietyVO);
		JSONObject jo = new JSONObject();
		if(resultDto.isSuccess()) {
			jo.put("result", MyConstants.AJAX_SUCCESS);
		}else {
			jo.put("result", MyConstants.AJAX_FAILED_ALERT);
			jo.put("msg", resultDto.getErrorMSG());
		}
		return jo;
	}

}
